@extends('Admin.layout.layout')
@section('title')
    <title>Love178官网 后台线下捐款列表</title>
@endsection

@section('con')
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">线下捐款列表</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <div class="row">
    	<div class="col-lg-12"> 
   <div class="panel panel-default"> 
    <div class="panel-heading">
      
    </div> 
    <!-- /.panel-heading --> 
    <div class="panel-body"> 
     <div class="dataTable_wrapper"> 
      <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
      <form action="{{url('/admin/loveuser/index')}}" method="get">
       <div class="row">
        <div class="col-sm-6">
         <div class="dataTables_length" id="dataTables-example_length">
          <label>显示 
          <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
          <option value="10" @if(!empty($data['num']) && $data['num'] == 10) selected @endif>10</option>
          <option value="25" @if(!empty($data['num']) && $data['num'] == 25) selected @endif>25</option>
          <option value="50" @if(!empty($data['num']) && $data['num'] == 50) selected @endif>50</option>
          <option value="100" @if(!empty($data['num']) && $data['num'] == 100) selected @endif>100</option>
          </select>条</label>
         </div>
        </div>
        <div class="col-sm-6">
         <div id="dataTables-example_filter" class="dataTables_filter">
          <label>查询:<input type="search" name="keywords" value="{{ $data['keywords'] or '' }}" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" /></label>
          <button class="btn">搜索</button>
         </div>
        </div>
       </div>
      </form>
       <div class="row">
        <div class="col-sm-12">
         <table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info"> 
          <thead> 
           <tr role="row">
            <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 175px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">ID </th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 203px;" aria-label="Browser: activate to sort column ascending">捐款人名</th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 184px;" aria-label="Platform(s): activate to sort column ascending">捐款金额</th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 150px;" aria-label="Engine version: activate to sort column ascending">捐款时间</th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 150px;" aria-label="Engine version: activate to sort column ascending">捐款电话</th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 150px;" aria-label="Engine version: activate to sort column ascending">捐款方式</th>
            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 108px;" aria-label="CSS grade: activate to sort column ascending">操作</th>
           </tr> 
          </thead> 
          <tbody> 

          @foreach($loveusers as $k=>$v)
           <tr class="gradeA odd" role="row"> 
            <td class="sorting_1">{{$v->id}}</td> 
            <td>{{$v->username}}</td> 
            <td>{{$v->account}}</td> 
            <td class="center">{{date('Y-m-d H:i:s',$v->time)}}</td> 
            <td>{{$v->phone}}</td>
            @if($v->status == 1)
            <td>网络捐款</td>
            @elseif($v->status ==0)
            <td>线下捐款</td>
            @endif
            <td class="center"><button class="btn btn-danger btn-xs btn-delete" type="button">删除</button>|<a href="{{url('/admin/loveuser/edit',['id'=>$v->id])}}" class="btn btn-warning btn-xs">修改</a></td> 
           </tr>
           @endforeach

          </tbody> 
         </table>
        </div>
       </div>
       <div class="row">
        
        <div class="col-sm-12">
         <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
          {!! $loveusers->appends($data)->render() !!}
         </div>
        </div>
       </div>
      </div> 
     </div> 
     <!-- /.table-responsive --> 
     
    </div> 
    <!-- /.panel-body --> 
   </div> 
   <!-- /.panel --> 
  </div>
  </div>
@endsection

@section('js')
   <script type="text/javascript">
    //查看是否引入jquery
    // alert($);
    
    $('.btn-delete').click(function(){
        //查看是否绑定删除按钮
    	// alert(1);

    	$.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
        });

    	//获取要删除语句的id
    	var id = $(this).parents('tr').find('.sorting_1').text();
    	// alert(id);
        
        var btn = $(this);
        //ajax地址,参数,匿名函数
    	$.post('/admin/loveuser/del',{id:id},function(data){

    	$.post('{{url("/admin/loveuser/del")}}',{id:id},function(data){

    		if(data == 1){
    			btn.parents('tr').remove();
    		}else{
    			alert('删除失败');
    		}

    	})
    })


   </script>

@endsection